package org.kunlong.netix.processor.standardprocessor;

import java.util.ArrayList;
import java.util.List;

public class JobPool {
	private int currentPosition = 0;
	private List<JobQueue> jobList = new ArrayList<JobQueue>();

	public void addJob(Job j) {
		JobQueue jq = jobList.get(currentPosition);
		jq.addJob(j);
		synchronized (jq) {
			jq.notify();// wake up the sleeping
		}
		currentPosition++;
		if (currentPosition == jobList.size()) {
			currentPosition = 0;
		}
	}
	public void init(int size){
		for(int i=0;i<size;i++){
			jobList.add(new JobQueue());
		}
	}
	public int getCurrentPosition() {
		return currentPosition;
	}

	public void setCurrentPosition(int currentPosition) {
		this.currentPosition = currentPosition;
	}

	public List<JobQueue> getJobList() {
		return jobList;
	}

	public void setJobList(List<JobQueue> jobList) {
		this.jobList = jobList;
	}
}
